import { postHandle } from '@/api'
export const mixin = {
  data() {
    return {
      hotWorkTypeData: [],
      possibleHazardsData: [],
      implementationData: [],
      safetyMeasuresData: [],
      memberData: [],
      approvalData: [],
      temporaryWorkersData: [],
      temporaryWorkersZSGData: [],
      maxPageSize: {
        p: 1,
        ps: 9999
      }
    }
  },
  computed: {
    entSpaceId() {
      return this.$store.getters.entSpaceId
    },
    spaceId() {
      return this.$store.getters.spaceId
    }
  },
  methods: {
    // 动火作业类型
    getHotWorkTypeData() {
      let params = {
        d: {
          filters: [
            {
              field: 'pdCode',
              operator: 'EQUALS',
              value: 'hotWorkType'
            }
          ],
          page: this.maxPageSize,
          sorts: [{ field: 'ct', isDesc: false }]
        }
      }
      postHandle('/api/v1/welder-sbtx-second/dictionary', params).then(res => {
        this.hotWorkTypeData = res.result
      })
    },
    // 可能产生的危害
    getPossibleHazardsData() {
      let params = {
        d: {
          filters: [
            {
              field: 'pdCode',
              operator: 'EQUALS',
              value: 'possibleHazards'
            }
          ],
          page: this.maxPageSize,
          sorts: [{ field: 'ct', isDesc: false }]
        }
      }
      postHandle('/api/v1/welder-sbtx-second/dictionary', params).then(res => {
        this.possibleHazardsData = res.result
      })
    },
    // 相关许可落实情况
    getImplementationData() {
      let params = {
        d: {
          filters: [
            {
              field: 'pdCode',
              operator: 'EQUALS',
              value: 'implementation'
            }
          ],
          page: this.maxPageSize,
          sorts: [{ field: 'ct', isDesc: false }]
        }
      }
      postHandle('/api/v1/welder-sbtx-second/dictionary', params).then(res => {
        this.implementationData = res.result
      })
    },
    // 安全措施
    getSafetyMeasuresData() {
      let params = {
        d: {
          filters: [
            {
              field: 'pdCode',
              operator: 'EQUALS',
              value: 'safetyMeasures'
            }
          ],
          page: this.maxPageSize,
          sorts: [{ field: 'ct', isDesc: false }]
        }
      }
      postHandle('/api/v1/welder-sbtx-second/dictionary', params).then(res => {
        this.safetyMeasuresData = res.result
      })
    },
    // 企业普通员工
    getMembersData() {
      let params = {
        d: {
          page: this.maxPageSize
        },
        obj: {
          roleCodes: ['formalEmployee'],
          spaceProperty: 2
        }
      }
      // /api/v1/welder-uac-second/space-user-member-comb/get-list
      postHandle('/api/v1/welder-uac-second/space-user-member-role-comb/get-user-info-by-roles', params).then(res => {
        this.memberData = res.result
      })
    },
    // 根据企业entSpaceId获取企业全部的管理员
    getApprovalData() {
      postHandle(`/api/v1/welder-uac-second/space-user-member-role-comb/get-ent-admin/${this.entSpaceId}`, {
        d: { page: this.maxPageSize }
      }).then(res => {
        this.approvalData = res.result
      })
    },
    // 项目临时工
    getTemporaryWorkersData() {
      let params = {
        d: {
          filters: [
            {
              field: 'workCode',
              operator: 'EQUALS',
              value: 'LSG'
            },
            {
              field: 'spaceId',
              operator: 'EQUALS',
              value: this.spaceId
            }
          ],
          page: this.maxPageSize
        },
        obj: {
          roleCodes: ['temporaryWorker'],
          spaceId: this.spaceId,
          spaceProperty: 1
        }
      }
      postHandle(`/api/v1/welder-uac-second/space-user-member-role-comb/get-user-info-by-roles`, params).then(res => {
        this.temporaryWorkersData = res.result
      })
    },
    // 项目正式工
    getTemporaryWorkersZSGData() {
      let params = {
        d: {
          filters: [
            {
              field: 'workCode',
              operator: 'EQUALS',
              value: 'ZSG'
            },
            {
              field: 'spaceId',
              operator: 'EQUALS',
              value: this.spaceId
            }
          ],
          page: this.maxPageSize
        },
        obj: {
          roleCodes: ['formalEmployee', 'proAdmin'],
          spaceId: this.spaceId,
          spaceProperty: 1
        }
      }
      postHandle(`/api/v1/welder-uac-second/space-user-member-role-comb/get-user-info-by-roles`, params).then(res => {
        this.temporaryWorkersZSGData = res.result
      })
    }
  },
  created() {

  }
}
